FROM golang:alpine AS builder

LABEL stage=gobuilder

ENV CGO_ENABLED 0


RUN apk update --no-cache && apk add --no-cache tzdata

WORKDIR /build

ADD go.mod .
ADD go.sum .
ENV GOPROXY=https://goproxy.cn
RUN go env -w GOPROXY=https://goproxy.cn
RUN GOPROXY=https://goproxy.cn go mod download -x
RUN go env

COPY . .

RUN go build -v -ldflags="-s -w" -o /app/demohttp demohttp.go


FROM scratch

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai

WORKDIR /app
COPY --from=builder /app/demohttp /app/demohttp
COPY ./etc /app/etc

CMD ["./demohttp"]
